/*
============================================================================
FileName	:	XQChatClientManager.h
Author		:	liyake
Website		:	http://www.liyake.com
Create Data	:	2012-03-08 13:07
Change Data	:	2012-03-08 13:07
Detail		:	The socket client of xqchat application
============================================================================
*/

#ifndef _XQCHAT_CLIENT_MANAGER_H_
#define _XQCHAT_CLIENT_MANAGER_H_

#include "XQChatRosterManager.h"
#include "XQChatClient.h"

namespace XQChat
{
	class CXQChatClientManager : public QObject
	{
		Q_OBJECT
	public:
		CXQChatClientManager(void);
		~CXQChatClientManager(void);

	public:
		CXQChatClient* addAccount(const QString& jid, const QString& password);	//error return 0;
		CXQChatRosterManager* getRosterManager();

	protected slots:
		void onClientConnected();
		void onClientDisconnected();
		void onClientError(QXmppClient::Error error);
		void onClientMsgReceived(const QXmppMessage &message);
		void onClientPresenceReceived(const QXmppPresence &presence);
		void onClientStateChanged(QXmppClient::State state);

signals:
		void rosterReceived();
		void presenceChanged(const QString& fullJid, const QString& resource);
		void rosterChanged(const QString& fullJid);
		void subscriptionReceived(const QString& fullJid);

	private:
		QMap<QString,CXQChatClient*> m_mapClients;
		CXQChatRosterManager* m_pRosterManager;

	public:
		static CXQChatClientManager* getQXChatClientManager();
	private:
		static CXQChatClientManager* m_pClientManager;
	};

}

#endif	//_XQCHAT_CLIENT_MANAGER_H_